package io.scnb.lesson001.demo16;

import org.junit.Test;

public class ProxyTest {

    @Test
    public void costTimeProxy() {
        IService serviceA = CostTImeInvocationHandler.createProxy(new ServiceA(), IService.class);
        IService serviceB = CostTImeInvocationHandler.createProxy(new ServiceB(), IService.class);

        serviceA.m1();
        serviceA.m2();
        serviceA.m3();

        serviceB.m1();
        serviceB.m2();
        serviceB.m3();
    }

    @Test
    public void userService() {
        IUserService userService = CostTImeInvocationHandler.createProxy(new UserService(), IUserService.class);
        userService.insert("scnb");
    }
}
